{php include pubTemplate("header")}

<script>
    $(document).ready(function() {

        //选择一级区域
        $('#cateid').change(function(){
            $("#select2").html('<img src="'+siteUrl+'public/images/loading.gif" />');
            var cateid = $(this).children('option:selected').val();  //弹出select的值

            if(cateid==0){
                $("#select2").html('');

            }else{

                $.ajax({
                    type: "GET",
                    url:  "{SITE_URL}index.php?app=article&ac=ajax&ts=twocate&referid="+cateid,
                    success: function(msg){
                        $("#select2").html(msg);
                    }
                });

            }

        });

    });
</script>



<div class="container">

    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{SITE_URL}">首页</a></li>
            <li class="breadcrumb-item"><a href="{tsUrl('article')}">文章</a></li>
            <li class="breadcrumb-item active" aria-current="page">写文章</li>
        </ol>
    </nav>


<div class="card">
  <div class="card-body">


<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">


<form method="POST" action="{SITE_URL}index.php?app=article&ac=add&ts=do" enctype="multipart/form-data">

  <div class="form-group">
    <label>标题：</label>
    <input name="title" type="text" class="form-control">
  </div>
{if $arrCate}  
  <div class="form-group">
    <label>分类：</label>

      <div class="row">
          <div class="col-6 col-md-6">

              <select id="cateid" name="cateid" class="form-control">
                  <option value="0">选择一级分类</option>
                  {loop $arrCate $key $item}
                  <option value ="{$item['cateid']}">{$item['catename']}</option>
                  {/loop}
              </select>

          </div>
          <div id="select2" class="col-6 col-md-6">



          </div>
      </div>

	
  </div>
{/if}

  <div class="form-group">
    <label>内容：</label>
      <div>
          <textarea  id="tseditor" name="content"></textarea>
      </div>
  </div>


    <div class="form-group">
        <label>内容概要：</label>
        <textarea class="form-control" name="gaiyao"></textarea>
    </div>
  
  <div class="form-group">
    <label>标签：</label>
    <input name="tag" type="text" class="form-control">
  </div>

   <div class="form-group">
    <label>封面图片：</label>

       <!--
       <div>
           <input type="file" name="photo" accept="image/jpeg,image/png"> <span class="fs12 c9">(支持jpg,png格式；大小640*400px)</span>
       </div>
       -->

       <div class="custom-file" onchange="imgView()">
           <input id="img-file" type="file" name="photo" class="custom-file-input" accept="image/jpeg,image/png">
           <label class="custom-file-label c9" for="img-file" data-browse="封面图">(支持jpg,png格式；大小640*360px)</label>
       </div>

       <div id="img-view" style="display: none;">
           <img src="" id="img-show" height="200">
       </div>

  </div>


    <div class="form-group">
        <label>查看需要：</label>
        <input type="text" name="score" value="0" onkeyup="NumberCheck(this)" /> 积分
    </div>



    <!--图片验证码-->
    {if $TS_SITE['isauthcode']}
    <div class="form-group">
        <label>验证码：</label>

        <div class="offset-0">
            <input class="form-control form-control-sm w-auto float-left mr-1" name="authcode" />
            <img class="mt-1" src="{SITE_URL}index.php?app=pubs&ac=code" onclick="javascript:newgdcode(this,this.src);" title="点击刷新验证码" alt="点击刷新验证码" style="cursor:pointer;"/>

        </div>


    </div>
    {/if}


    <!--人机验证-->
    {if $TS_SITE['is_vaptcha']}
    <div class="form-group">
        <label>人机验证：</label>

        <div class="offset-0">
            
            <div id="vaptchaContainer" style="width: 300px;height: 36px;">
                <div class="vaptcha-init-main">
                <div class="vaptcha-init-loading">
                    <a href="/" target="_blank">
                    <img src="https://r.vaptcha.net/public/img/vaptcha-loading.gif" />
                    </a>
                    <span class="vaptcha-text">Vaptcha启动中...</span>
                </div>
                </div>
            </div>
            <script src="https://v.vaptcha.com/v3.js"></script>
            <script>
                vaptcha({
                    vid: '{$TS_SITE[vaptcha_vid]}',
                    type: 'click',
                    container: '#vaptchaContainer',
                    offline_server: "{SITE_URL}index.php?app=pubs&ac=vaptcha",
                }).then(function (vaptchaObj) {
                    vaptchaObj.render()
                    vaptchaObj.renderTokenInput('#vaptcha-token')
                })
            </script>

        </div>

        <div id="vaptcha-token"></div>

    </div>
    {/if}


  
<input type="hidden" name="token" value="{$_SESSION['token']}" />
<button class="btn btn-sm btn-info" type="submit">发布文章</button>

    <a class="btn btn-sm btn-outline-secondary" href="{tsUrl('article')}">取消发布</a>
  
</form>


</div>
<div class="col-md-2"></div>
</div>



</div>
</div>





</div>
{php doAction('tseditor')}
{php include pubTemplate("footer")}